//
//  AnnounceListViewController.m
//  AppleMarket
//
//  Created by yangy on 31/10/2018.
//  Copyright © 2018 szgsy. All rights reserved.
//

#import "AnnounceListViewController.h"

// view
#import "AnnounceListView.h"
// viewModel
#import "AnnounceViewModel.h"
// model
#import "NewsModel.h"
// controller
#import "WYWebController.h"

@interface AnnounceListViewController ()
@property (nonatomic, strong) AnnounceListView *listView;
@property (nonatomic, strong) AnnounceViewModel *viewModel;
@end

@implementation AnnounceListViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    self.title = @"公告列表";
    [self.view addSubview:self.listView];
    [self bindViewModel];
    
    [_listView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_equalTo(UIEdgeInsetsMake(0, 0, 0, 0));
    }];
}

- (void) bindViewModel
{
    [self.viewModel.detailClickSubject subscribeNext:^(id  _Nullable x) {
        // 公告详情
        NewsModel *n = (NewsModel*) x;
        WYWebController *webVC = [WYWebController webControllerWithTitle:n.DocTitle content:n.DocContent];
        [self bh_PushViewController:webVC hiddenTabbar:YES];
    }];
}

- (AnnounceListView *)listView
{
    if(!_listView){
        _listView = [[AnnounceListView alloc] initWithFrame:CGRectZero viewModel:self.viewModel];
    }
    return _listView;
}

- (AnnounceViewModel *)viewModel
{
    if(!_viewModel){
        _viewModel = [[AnnounceViewModel alloc] init];
    }
    return _viewModel;
}

@end
